﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TVC.Modules.CustomControl
{
    public class MyScheduleBox : Gizmox.WebGUI.Forms.ScheduleBox
    {
        private System.Globalization.CultureInfo mobjCustomCulture = null;
        private System.Globalization.CultureInfo mobjSavedCulture = null;

        private void SetCustomCulture()
        {
            if (mobjCustomCulture == null)
            {
                mobjCustomCulture = System.Globalization.CultureInfo.CreateSpecificCulture(System.Threading.Thread.CurrentThread.CurrentCulture.Name);
                string[] myDateTimePatterns = new string[] { "ddd MM/dd/yy", "ddd MM/dd/yyyy" };
                mobjCustomCulture.DateTimeFormat.SetAllDateTimePatterns(myDateTimePatterns, 'd');
            }
            mobjSavedCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture = mobjCustomCulture;
        }

        private void RestoreCulture()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = mobjSavedCulture;
        }
        protected override void RenderAttributes(Gizmox.WebGUI.Common.Interfaces.IContext objContext, Gizmox.WebGUI.Common.Interfaces.IAttributeWriter objWriter)
        {
            SetCustomCulture();
            base.RenderAttributes(objContext, objWriter);
            RestoreCulture();
        }
        //protected override void RenderAttributes(Gizmox.WebGUI.Common.Interfaces.IContext objContext, Gizmox.WebGUI.Common.Interfaces.IAttributeWriter objWriter)
        //{
        //    SetCustomCulture();
        //    base.RenderAttributes(objContext, objWriter);
        //    RestoreCulture();
        //}
    }
}